--- title: styled description: "The `styled` function generates a JSX element that allows styling using props." --- ## Overview `styled` is an object of JSX elements enabled with Yamada UI's style system, and can also be used as a function for custom components to receive Yamada UI's style system. ## Usage Use the `styled.` notation to generate an HTML element with [Style Props](https://yamada-ui.com/docs/styling/style-props.md). For example, to generate an `button` element with [Style Props](https://yamada-ui.com/docs/styling/style-props.md), write ``. ```tsx ``` ### Create a component `styled` can be used in two ways: as an object of JSX elements (``) and as a function that returns a JSX element (`styled('div')`). The function is suitable for generating simple components. ```tsx import { styled } from "@workspaces/ui" const Button = styled("button") const App = () => { return } ``` You can also pass a custom component to the argument and generate a custom component with [Style Props](https://yamada-ui.com/docs/styling/style-props.md). ```tsx import { styled } from "@workspaces/ui" import { YourComponent } from "./your-component" const NewComponent = styled(YourComponent) const App = () => { return } ``` ### Styling You can set default styles for a component or set styles based on conditions such as `variant` and `size`. #### Base Style Base style sets the default styles for a component. ```tsx const Button = styled("button", { base: { alignItems: "center", appearance: "none", cursor: "pointer", display: "inline-flex", fontWeight: "medium", justifyContent: "center", overflow: "hidden", position: "relative", rounded: "l2", transitionDuration: "moderate", transitionProperty: "common", userSelect: "none", verticalAlign: "middle", whiteSpace: "nowrap", _readOnly: { layerStyle: "readOnly" }, _disabled: { layerStyle: "disabled" }, }, }) ``` #### Variant Style Variant style sets styles based on the `variant` of the component. ```tsx const Button = styled("button", { variants: { outline: { layerStyle: "outline", _hover: { layerStyle: "outline.hover" }, }, solid: { layerStyle: "solid", _hover: { layerStyle: "solid.hover" }, }, subtle: { layerStyle: "subtle", _hover: { layerStyle: "subtle.hover" }, }, }, }) ``` To apply the variant style, set the `variant` value. ```tsx