Help with checkbox props mismatching storybook controls #586
-
Hello, I'm a big fan of this project and am considering using for my company's design system. We are using storybook js to build it which i think you guys are familiar with since its part of some of the pkgs here. Currently, i'm just trying to get a very simple However i'm running into something weird: i only see 5 controls/props in storybook, but the radix docs show 9 props. The description is also missing. My code:
It seems like Any help is much appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
Hi @acc-nicholas, thanks for your question, glad you like the components. So in the docs I see:
and in your story I see:
I understand the confusion. I'll try and point out where the "missing" ones come from.
I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Oh I just realised also that the way you're setting the types on your component is not right. Regardless, as I was saying earlier, If you don't care about polymorphism, you only need I don't really know how the controls thing you're doing works, but looking at the code I'm guessing it's based on that template to which you give the props through the generic. type Props = React.ComponentProps<typeof Checkbox>;
const Template: Story<Props> = (args) => (
<Checkbox {...args} />
);
export const Default = Template.bind({}); I think the only issue you'll have with this is that the type of the |
Beta Was this translation helpful? Give feedback.
Oh I just realised also that the way you're setting the types on your component is not right.
I'm a bit confused as well because I see you referencing
RadixCheckbox.CheckboxOwnProps
but we don't export types so I'm wondering how that even works 🙂Regardless, as I was saying earlier,
CheckboxOwnProps
will only contain the props we've explicitly added to it.If you don't care about polymorphism, you only need
React.elementRef
andReact.ComponentProps
(see in link below).If you do need polymorphism, you can use our type helpers.
Have a look here for an example of both: https://radix-ui.com/primitives/docs/overview/styling#styling-a-part
I don't really know how the controls thing you're doin…