
TypeScript Beyond Basics
} -->
When building UI libraries, components, or even small reusable elements in an app, documenting them right away is something I’ve learned to treat as essential - not optional.
In this post, I want to share why that matters, what problems it solves, and how I use Storybook to keep UI documentation clear, isolated, and accessible — not just for developers.
We all know the story: you finish a new component, maybe a Button
, and think:
“I’ll add the docs later - I just need to move on for now.”
A week passes. Then another component. Suddenly, the context is gone, you don’t remember what variants were meant to do, or how the props interact. At that point, documenting feels like a chore.
That’s why I always write the docs as I build. It’s part of the development checklist, just like writing unit tests or styling.
Here are a few reasons why I believe writing UI docs (and especially using Storybook) is worth the effort:
Card
and Modal
have different paddings - it’s instantly obvious.I use Storybook because it integrates well with modern frameworks (Vue, React, etc.) and encourages this idea of isolated components - rendered outside the app, with mock data and controls.
Here’s a minimal example for a simple Button
component:
// Button.tsx
export type ButtonProps = {
label: string;
variant?: "primary" | "secondary";
disabled?: boolean;
};
export const Button = ({ label, variant = "primary", disabled = false }: ButtonProps) => {
return (
<button className={`btn ${variant}`} disabled={disabled}>
{label}
</button>
);
};
// Button.stories.tsx
import type { Meta, StoryObj } from "@storybook/react";
import { Button } from "./Button";
const meta: Meta<typeof Button> = {
component: Button,
title: "UI/Button",
tags: ["autodocs"],
argTypes: {
variant: { control: "radio", options: ["primary", "secondary"] },
},
};
export default meta;
type Story = StoryObj<typeof Button>;
export const Primary: Story = {
args: {
label: "Click me",
variant: "primary",
},
};
export const Secondary: Story = {
args: {
label: "Cancel",
variant: "secondary",
},
};
export const Disabled: Story = {
args: {
label: "Can't touch this",
disabled: true,
},
};
With this setup, anyone on the team can:
Writing UI docs feels like a small task - until you skip it. Then it becomes a big one.
If you want a design system, or even just a consistent UI experience, documenting components early and often is key. It’s not just for others. It’s for you, your future self, and the codebase you’ll have to maintain.
And for me, Storybook is the best way to make that painless.
Bartłomiej Nowak
Programmer
Programmer focused on performance, simplicity, and good architecture. I enjoy working with modern JavaScript, TypeScript, and backend logic — building tools that scale and make sense.