diff --git a/packages/kubrick/src/Select/Select.stories.tsx b/packages/kubrick/src/Select/Select.stories.tsx index 9210547..efead7f 100644 --- a/packages/kubrick/src/Select/Select.stories.tsx +++ b/packages/kubrick/src/Select/Select.stories.tsx @@ -152,4 +152,23 @@ export const WithDescriptionBeforeInput: Story = { render: Default.render, }; +export const WithAfffix: Story = { + args: { + 'aria-label': 'Frequency', + description: 'Select the frequency for the site.', + label: '', + prefix: 'Frequency:', + suffix: 'Hz', + }, + render(props) { + return ( + + ); + }, +}; + export default meta; diff --git a/packages/kubrick/src/Select/Select.tsx b/packages/kubrick/src/Select/Select.tsx index 4d0c4a9..1b94b8f 100644 --- a/packages/kubrick/src/Select/Select.tsx +++ b/packages/kubrick/src/Select/Select.tsx @@ -33,7 +33,15 @@ interface SelectProps descriptionArea?: 'after-input' | 'before-input'; label?: ReactNode; name: string; + /** + * Content or element to dis before the input. + */ + prefix?: ReactNode; selectedItem?: string; + /** + * Content or element to display after the input. + */ + suffix?: ReactNode; } function determineKey(props: OptionProps) { @@ -84,7 +92,9 @@ export const Select = forwardRef( isRequired, label, name, + prefix, selectedItem, + suffix, } = props; const ref = useObjectRef(forwardedRef); const { clsx, componentProps, rootProps } = useProps('Select', props); @@ -144,30 +154,57 @@ export const Select = forwardRef( : ''} )} - + {prefix && ( +
+ {prefix} +
+ )} + + {suffix && ( +
+ {suffix} +
+ )} + {errorMessageList.length >= 1 && (