diff --git a/apps/website/docs/apis/checkbox.md b/apps/website/docs/apis/checkbox.md index 5875b5f..193a36c 100644 --- a/apps/website/docs/apis/checkbox.md +++ b/apps/website/docs/apis/checkbox.md @@ -42,7 +42,7 @@ Other props are as follows: The icon to display when the component is checked. - Type: `ReactNode` -- Default: ``, where `` is an icon component imported from [react-icons](https://www.npmjs.com/package/react-icons). +- Default: ``, where `` is an icon component imported from [react-icons](https://www.npmjs.com/package/react-icons). ### `color` @@ -71,7 +71,7 @@ This does not set the native input element to indeterminate due to inconsistent The icon to display when the component is indeterminate. - Type: `ReactNode` -- Default: ``, where `` is an icon component imported from [react-icons](https://www.npmjs.com/package/react-icons). +- Default: ``, where `` is an icon component imported from [react-icons](https://www.npmjs.com/package/react-icons). ### `label` diff --git a/apps/website/docs/apis/icon-adapter.md b/apps/website/docs/apis/icon-adapter.md index 299ab5e..581118b 100644 --- a/apps/website/docs/apis/icon-adapter.md +++ b/apps/website/docs/apis/icon-adapter.md @@ -5,6 +5,8 @@ title: # IconAdapter API + + API reference docs for the React IconAdapter component. Learn about the props of this exported module. diff --git a/apps/website/docs/components/button-group.mdx b/apps/website/docs/components/button-group.mdx index 5820c61..78a7335 100644 --- a/apps/website/docs/components/button-group.mdx +++ b/apps/website/docs/components/button-group.mdx @@ -26,9 +26,7 @@ export function ButtonGroupBasics() { - - - + @@ -38,12 +36,7 @@ export function ButtonGroupBasics() { ```jsx -import { - Button, - ButtonGroup, - IconAdapter, - IconButton, -} from 'tailwind-joy/components'; +import { Button, ButtonGroup, IconButton } from 'tailwind-joy/components'; import { MdSettings } from 'react-icons/md'; export function ButtonGroupBasics() { @@ -54,9 +47,7 @@ export function ButtonGroupBasics() { - - - + @@ -279,9 +270,7 @@ export function ButtonGroupDisabled() { - - - + @@ -291,12 +280,7 @@ export function ButtonGroupDisabled() { ```jsx -import { - Button, - ButtonGroup, - IconAdapter, - IconButton, -} from 'tailwind-joy/components'; +import { Button, ButtonGroup, IconButton } from 'tailwind-joy/components'; import { MdSettings } from 'react-icons/md'; export function ButtonGroupDisabled() { @@ -307,9 +291,7 @@ export function ButtonGroupDisabled() { - - - + @@ -330,9 +312,7 @@ export function ButtonGroupSpacing() { - - - + @@ -342,12 +322,7 @@ export function ButtonGroupSpacing() { ```jsx -import { - Button, - ButtonGroup, - IconAdapter, - IconButton, -} from 'tailwind-joy/components'; +import { Button, ButtonGroup, IconButton } from 'tailwind-joy/components'; import { MdSettings } from 'react-icons/md'; export function ButtonGroupSpacing() { @@ -358,9 +333,7 @@ export function ButtonGroupSpacing() { - - - + @@ -380,9 +353,7 @@ export function ButtonGroupVertical() { - - - + @@ -390,9 +361,7 @@ export function ButtonGroupVertical() { - - - + @@ -400,9 +369,7 @@ export function ButtonGroupVertical() { - - - + @@ -410,9 +377,7 @@ export function ButtonGroupVertical() { - - - + @@ -422,12 +387,7 @@ export function ButtonGroupVertical() { ```jsx -import { - Button, - ButtonGroup, - IconAdapter, - IconButton, -} from 'tailwind-joy/components'; +import { Button, ButtonGroup, IconButton } from 'tailwind-joy/components'; import { MdSettings } from 'react-icons/md'; export function ButtonGroupVertical() { @@ -438,9 +398,7 @@ export function ButtonGroupVertical() { - - - + @@ -448,9 +406,7 @@ export function ButtonGroupVertical() { - - - + @@ -458,9 +414,7 @@ export function ButtonGroupVertical() { - - - + @@ -468,9 +422,7 @@ export function ButtonGroupVertical() { - - - + @@ -490,9 +442,7 @@ export function ButtonGroupStretching1() { - - - + @@ -502,12 +452,7 @@ export function ButtonGroupStretching1() { ```jsx -import { - Button, - ButtonGroup, - IconAdapter, - IconButton, -} from 'tailwind-joy/components'; +import { Button, ButtonGroup, IconButton } from 'tailwind-joy/components'; import { MdSettings } from 'react-icons/md'; export function ButtonGroupStretching1() { @@ -518,9 +463,7 @@ export function ButtonGroupStretching1() { - - - + @@ -645,5 +588,4 @@ See the documentation below for a complete reference to all of the props availab - [` - @@ -274,30 +260,16 @@ export function ButtonDecorators() { ```jsx -import { Button, IconAdapter } from 'tailwind-joy/components'; +import { Button } from 'tailwind-joy/components'; import { MdAdd, MdKeyboardArrowRight } from 'react-icons/md'; export function ButtonDecorators() { return (
- -
@@ -355,15 +327,7 @@ export function ButtonLoadingPosition() { - @@ -373,7 +337,7 @@ export function ButtonLoadingPosition() { ```jsx -import { Button, IconAdapter } from 'tailwind-joy/components'; +import { Button } from 'tailwind-joy/components'; import { MdSend } from 'react-icons/md'; export function ButtonLoadingPosition() { @@ -382,15 +346,7 @@ export function ButtonLoadingPosition() { - @@ -412,24 +368,16 @@ export function IconButtonBasics() { return ( - - - + - - - + - - - + - - - + ); @@ -438,43 +386,29 @@ export function IconButtonBasics() { ```jsx -import { IconAdapter, IconButton } from 'tailwind-joy/components'; +import { IconButton } from 'tailwind-joy/components'; import { MdFavoriteBorder } from 'react-icons/md'; export function IconButtonBasics() { return (
- - - + - - - + - - - + - - - +
); } ``` -:::info - -[``](./icon-adapter) is an original component of Tailwind-Joy. - -::: - ## Anatomy The Button component is composed of a single root ` diff --git a/packages/tailwind-joy/src/components/Checkbox.tsx b/packages/tailwind-joy/src/components/Checkbox.tsx index d8054a1..65e7fe5 100644 --- a/packages/tailwind-joy/src/components/Checkbox.tsx +++ b/packages/tailwind-joy/src/components/Checkbox.tsx @@ -15,7 +15,7 @@ import { textColor, toVariableClass, } from '../base/modifier'; -import { IconAdapter } from './IconAdapter'; +import { adaptAsIcon } from './internal/class-adapter'; const checkboxRootVariants = ( props?: BaseVariants & { @@ -326,18 +326,17 @@ export const Checkbox = forwardRef( {disableIcon ? null : indeterminate - ? indeterminateIcon ?? ( - - - - ) + ? indeterminateIcon + ? adaptAsIcon(indeterminateIcon, { color: instanceColor, size }) + : adaptAsIcon(, { + color: instanceColor, + size, + }) : instanceChecked - ? checkedIcon ?? ( - - - - ) - : uncheckedIcon} + ? checkedIcon + ? adaptAsIcon(checkedIcon, { color: instanceColor, size }) + : adaptAsIcon(, { color: instanceColor, size }) + : adaptAsIcon(uncheckedIcon, { color: instanceColor, size })} {label && (