Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation of "Targeting slots" has incorrect description. #2572

Closed
IkumaTadokoro opened this issue May 8, 2024 · 0 comments
Closed

Explanation of "Targeting slots" has incorrect description. #2572

IkumaTadokoro opened this issue May 8, 2024 · 0 comments

Comments

@IkumaTadokoro
Copy link

Subject

concepts

Description

Targeting slots includes this description and sample code.

Let's say you want to apply a different border color to the checkbox control based on the size and the checked state. Here's how you would do it:

import { sva } from '../styled-system/css'
 
const button = sva({
  className: 'btn',
  slots: ['root', 'text'],
  base: {
    root: {
      bg: 'blue.500',
      _hover: {
        // v--- 🎯 this will target the `text` slot
        '& .btn__text': {
          color: 'white'
        }
      }
    }
  }
})

However, this sample code doesn't match the description.

Compound variants above the Targeting slots also has same description and sample code has border color.

Let's say you want to apply a different border color to the checkbox control based on the size and the checked state. Here's how you would do it:

import { sva } from '../styled-system/css'
const checkbox = sva({
  slots: ['root', 'control', 'label'],
  base: {...},
  variants: {
    size: {
      sm: {...},
      md: {...}
    },
    isChecked: {
      true: { control: {}, label: {} }
    }
  },
  compoundVariants: [
    {
      size: 'sm',
      isChecked: true,
      css: {
        control: { borderColor: 'green-500' }
      }
    }
  ],
  defaultVariants: {...}
})

I think that the description in Targeting slots should be deleted or change.

@chakra-ui chakra-ui locked and limited conversation to collaborators May 8, 2024
@segunadebayo segunadebayo converted this issue into discussion #2573 May 8, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant