Better understanding component driven development #32133
Replies: 1 comment
-
Component-driven development (CDD) is about building UIs from small, focused components upward, developing and testing each in isolation. Storybook is designed for this: it lets you work on components in specific states without spinning up your whole app, and encourages a bottom-up workflow where you start with basic components and compose them into more complex ones "Storybook is an interactive directory of your UI components and their stories". For your specific dilemma—whether to use a full backend-derived
Storybook controls: By default, Storybook will try to generate controls for every field in your prop types, which can get noisy with complex objects. You can customize this using the export default {
component: UserInfo,
parameters: {
docs: {
controls: { exclude: ['is_active', 'is_staff', 'is_superuser', 'last_login', 'id', 'created', 'modified', 'profile_photo_url'] }
}
}
}; This will hide those fields from the controls UI, making your stories much clearer "Storybook allows customization of the Controls panel by using parameters to exclude specific props". Summary:
This approach keeps your components focused, your stories readable, and your codebase maintainable as your app grows. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi! I'm coming from data background where I've traditionally focused on TDD in languages such as python. I'm now building a frontend with sveltekit and trying to understand how to leverage storybook for CDD effectively. At a high level it makes sense to me, but I think there are a lot of micro-decisions I'm unsure about the implications of, in particular to general design patterns and interfaces. This may not be an entirely storybook focused discussion, but I'd appreciate any advice.
I'm going to borrow some code from shadcn-svelte for this example. Let's say I have a component like this:
In this example, I am recycling my user type
User
from my OpenAPI schema generated by my backend. On some level that feels nice because I don't have to define a second type. However, this type contains a lot of items that are not relevant to this component, when it comes to loading this into storybook, I see a lot of noise. Let's assume this type:We can see we have a lot of info that's just not used. And when viewing this in storybook with this setup:
I see my user type looks quite noisy, and suddenly this component feels more complex and opaque than it really is.

So then I'm left with the question: is this the right approach here? It seems my choices would either be:
It's possible the answer here for experienced frontend devs is pretty clear, so if so I'd be interested in hearing it. Ultimately I'm interested in the driven aspect of component driven development. I don't just want to use storybook as a tool, I want to better understand the paradigm behind this approach that helps guide these sort of decisions.
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions