--- title: Slide description: "`Slide`は、要素をページの隅から表示または非表示にするコンポーネントです。" links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/slide/slide.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/slide - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-slide--basic --- ```tsx const [open, { toggle }] = useBoolean() return ( <> クリリンのことか……クリリンのことかーーーっ!!!!! ) ``` ## 使い方 ```tsx import { Slide } from "@yamada-ui/react" ``` ```tsx import { Slide } from "@/components/ui" ``` ```tsx import { Slide } from "@workspaces/ui" ``` ```tsx ``` ### 表示位置を変更する 表示位置を変更する場合は、`placement`に`"block-start"`、`"block-end"`、`"inline-start"`、または`"inline-end"`を設定します。デフォルトでは、`"inline-end"`が設定されています。 ```tsx const placements = ["block-start", "block-end", "inline-start", "inline-end"] const [placement, setPlacement] = useState("inline-end") const [open, { toggle }] = useBoolean() return ( {placements.map((value) => ( ))} クリリンのことか……クリリンのことかーーーっ!!!!! ) ``` ### アニメーション時間を変更する アニメーション時間を変更する場合は、`duration`に数値(秒単位)を設定します。デフォルトは`{ enter: 0.4, exit: 0.3 }`です。 ```tsx const [open, { toggle }] = useBoolean() return ( <> クリリンのことか……クリリンのことかーーーっ!!!!! ) ``` ### 非表示時にアンマウントする コンポーネントが表示されていないときにアンマウントする場合は、`unmountOnExit`を`true`に設定します。 ```tsx const [open, { toggle }] = useBoolean() return ( <> クリリンのことか……クリリンのことかーーーっ!!!!! ) ``` ### 遅延させる アニメーションを遅延させる場合は、`delay`に数値(秒単位)を設定します。 ```tsx const [open, { toggle }] = useBoolean() return ( <> クリリンのことか……クリリンのことかーーーっ!!!!! ) ``` ## Props | Prop | Default | Type | Description | | --------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `as` | - | `keyof IntrinsicElements` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `enter` | - | `any` | Custom `enter`. | | `exit` | - | `any` | Custom `exit`. A target to animate to when this component is removed from the tree. This component **must** be the first animatable child of an `AnimatePresence` to enable this exit animation. This limitation exists because React doesn't allow components to defer unmounting until after an animation is complete. Once this limitation is fixed, the `AnimatePresence` component will be unnecessary. | | `initial` | - | `any` | Custom `initial`. Properties, variant label or array of variant labels to start in. Set to `false` to initialise with the values in `animate` (disabling the mount animation) | | `delay` | `0` | `MotionLifecycleProps \| number` | Custom `delay` definition for `enter` and `exit`. | | `duration` | `0.2` | `MotionLifecycleProps \| number` | Custom `duration` definition for `enter` and `exit`. | | `open` | - | `boolean` | Show the component. triggers when enter or exit states. | | `placement` | `"inline-end"` | `"block-end" \| "block-start" \| "inline-end" \| "inline-start" ...` | The placement of the slide. | | `transition` | - | `MotionLifecycleProps` | Custom `transition` definition for `enter` and `exit`. | | `transitionEnd` | - | `MotionLifecycleProps` | Custom `transitionEnd` definition for `enter` and `exit`. | | `unmountOnExit` | - | `boolean` | If `true`, the element will unmount when `open={false}` and animation is done. |