Skip to content

useContainerQuery hook or containerSize property #7615

Answered by timkindberg
VaZark asked this question in Ideas
Discussion options

You must be logged in to vote

I realized you can also write it like this, with the styles located on the element they are styling. A bit better having the styles colocated.

import { ChakraProvider, Box, Stack, Text } from "@chakra-ui/react";

export default function App() {
  return (
    <div className="App">
      <ChakraProvider>
        <Box
          sx={{
            containerType: "inline-size",
          }}
        >
          <Stack
            sx={{
              "@container (min-width: 0px)": {
                "&": { p: 6, bg: "green.100" },
              },
              "@container (min-width: 480px)": {
                "&": { p: 12, bg: "gray.100" },
              },
              "@container (min-width:…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@timkindberg
Comment options

Answer selected by VaZark
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants