import React from 'react'
import { type Meta, type StoryFn } from '@storybook/react'
import { Heading } from '~components/Heading'
import { Text } from '~components/Text'
export default {
title: 'Guides/Tailwind/Utility Class References/Modifiers/Container Queries',
parameters: {
docsLayout: 'fullPage',
docs: {
a11y: { disable: true },
description: {
component: 'Require @kaizen/tailwind and add it into your tailwind config',
},
},
},
} satisfies Meta
type ContainerQueryInfoProps = {
selector: string
selectorValue: string
children: React.ReactElement
}
const ContainerQueryInfo = ({
selector,
selectorValue,
children,
}: ContainerQueryInfoProps): React.ReactElement => (
Container query selector: @{selector}
Breakpoint: {selectorValue}
In this example: @{selector}:bg-blue-400
{/* Container wrapper to demonstrate container queries */}
Container wrapper (resize to see effect)
{children}
)
export const ContainerQueries: StoryFn = () => (
Container query breakpoints activate based on the container's width, not the
viewport. These elements will change color when their parent container reaches the specified
width.
)
export const ArbitraryContainerQueries: StoryFn = () => (
Custom container query breakpoints can be created with arbitrary values.
Custom container width breakpoint (applied when the container gets wider
than 500px)
In this example: @[500px]:bg-green-400
Container wrapper (resize to see effect)
)
export const NamedContainers: StoryFn = () => (
Named containers allow you to query specific containers by name, useful when you have nested
containers.
Named container example - The inner element responds to the outer
"sidebar" container, not the inner "card" container
In this example: @container/sidebar and @md/sidebar:bg-green-400
Outer container ("sidebar") - resize to see effect
Inner container ("card")
Responds to sidebar container
)