diff --git a/README.md b/README.md index 0c8d4f63..9ee48940 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ You can also try out the following sandbox examples: - [Custom loader & clear button](https://codesandbox.io/s/rbt-custom-aux-components-gn3kn) - [Multi-select with reorderable drag & drop tokens](https://codesandbox.io/s/rbt-drag-drop-token-example-u43sf) - [Keep the menu open during multi-selection](https://codesandbox.io/s/rbt-keep-menu-open-during-multi-select-nr2y4) +- [Single-select with floating label (BS5)](https://codesandbox.io/s/rbt-floating-labels-8c2j6b) If you have an example use case that would be useful to others, please create a sandbox and submit a pull request to add it to the list! diff --git a/src/components/Typeahead/Typeahead.stories.tsx b/src/components/Typeahead/Typeahead.stories.tsx index 2c6467c9..f212fa0a 100644 --- a/src/components/Typeahead/Typeahead.stories.tsx +++ b/src/components/Typeahead/Typeahead.stories.tsx @@ -5,6 +5,7 @@ import React, { useState } from 'react'; import { Story, Meta } from '@storybook/react'; import Typeahead, { TypeaheadComponentProps } from './Typeahead'; +import Hint from '../Hint'; import Menu from '../Menu'; import MenuItem from '../MenuItem'; @@ -94,6 +95,27 @@ AllowNew.args = { allowNew: true, }; +export const CustomInput = Template.bind({}); +CustomInput.args = { + ...defaultProps, + renderInput: ({ inputRef, referenceElementRef, ...inputProps }) => ( + +
+ { + inputRef(node); + referenceElementRef(node); + }} + /> + +
+
+ ), +}; + export const CustomMenu = Template.bind({}); CustomMenu.args = { ...defaultProps, diff --git a/src/components/Typeahead/__snapshots__/Typeahead.test.tsx.snap b/src/components/Typeahead/__snapshots__/Typeahead.test.tsx.snap index 7de8f354..d4ce1a9c 100644 --- a/src/components/Typeahead/__snapshots__/Typeahead.test.tsx.snap +++ b/src/components/Typeahead/__snapshots__/Typeahead.test.tsx.snap @@ -207,6 +207,77 @@ exports[` Controlled story renders snapshot 1`] = ` `; +exports[` CustomInput story renders snapshot 1`] = ` +
+
+
+ + +
+ +
+
+`; + exports[` CustomMenu story renders snapshot 1`] = `