Tools

React Props Generator

Designing good component APIs is harder than writing internal logic. This generator gives you prop names following React conventions, with TypeScript types included for more predictable and user-friendly components.

Instant🔒In your browserNo signup
Live
    View as text

    React naming conventions

    Event handlers start with 'on' followed by the past tense verb of the event: onClick, onChange, onSubmit. This differentiates handlers (callbacks your component receives) from internal methods (handleClick, handleChange). A Button component should receive onClick, not handleClick. The 'handle' prefix is for your component's private methods.

    Boolean props use is/has/should prefixes: isOpen, hasError, shouldRender. Avoid negatives like isNotDisabled; prefer: isEnabled. Double negatives (disabled={!isNotHidden}) confuse. One exception: disabled is idiomatic in HTML, so disabled (not isDisabled) is fine for DOM consistency.

    Content props accepting React.ReactNode should have descriptive names: leftIcon not icon, emptyState not fallback, errorMessage not error (error is better for the Error object). This makes code self-documenting:

    FAQ

    When to use optional vs required props?

    Make optional what has a reasonable default (size, variant). Require what's essential for the component to work (data in a DataTable, children in a Container). Optional props without defaults should have clear fallback behavior.

    Should I prefix all props?

    No. Prefixes like is/has/on are useful conventions but not rigid. Use onClick for handlers, isOpen for booleans. But children, className, title don't need prefixes; they're idiomatic without them.

    How to name props that accept components?

    Use descriptive nouns: icon, header, footer, emptyState. If your prop is a complete component, use PascalCase: IconComponent, HeaderComponent. This differentiates instances (<Icon />) from definitions (Icon).

    What convention for styling props?

    Always include className to allow style override. Consider variant/size for predefined variations. Avoid exposing all CSS props individually (backgroundColor, fontSize); that breaks encapsulation. Use className or style for edge cases.

    Was this generator useful?