-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ToggleButtonGroup to RAC Tailwind starter kit
- Loading branch information
1 parent
8aed065
commit c7bc7c0
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { ToggleButtonGroup as RACToggleButtonGroup, ToggleButtonGroupProps } from 'react-aria-components'; | ||
import { tv } from 'tailwind-variants'; | ||
|
||
const styles = tv({ | ||
base: 'flex gap-1', | ||
variants: { | ||
orientation: { | ||
horizontal: 'flex-row', | ||
vertical: 'flex-col' | ||
} | ||
} | ||
}); | ||
|
||
export function ToggleButtonGroup(props: ToggleButtonGroupProps) { | ||
return ( | ||
<RACToggleButtonGroup | ||
{...props} | ||
className={styles({orientation: props.orientation || 'horizontal', className: props.className})} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { Meta } from '@storybook/react'; | ||
import React from 'react'; | ||
import { ToggleButton } from '../src/ToggleButton'; | ||
import { ToggleButtonGroup } from '../src/ToggleButtonGroup'; | ||
import { Bold, Italic, Underline } from 'lucide-react' | ||
|
||
const meta: Meta<typeof ToggleButtonGroup> = { | ||
component: ToggleButtonGroup, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Example = (args: any) => ( | ||
<ToggleButtonGroup {...args}> | ||
<ToggleButton id="bold" aria-label="Bold"><Bold className="w-4 h-4" /></ToggleButton> | ||
<ToggleButton id="italic" aria-label="Italic"><Italic className="w-4 h-4" /></ToggleButton> | ||
<ToggleButton id="underline" aria-label="Underline"><Underline className="w-4 h-4" /></ToggleButton> | ||
</ToggleButtonGroup> | ||
); | ||
|
||
Example.args = { | ||
selectionMode: 'multiple' | ||
}; |