Skip to content

Feature: new re-usable component system#6

Merged
sn merged 4 commits into
mainfrom
feature/re-usable-components
Jan 29, 2026
Merged

Feature: new re-usable component system#6
sn merged 4 commits into
mainfrom
feature/re-usable-components

Conversation

@sn
Copy link
Copy Markdown
Contributor

@sn sn commented Jan 29, 2026

This pull request introduces a new declarative component system to NitroUI, making it easier to build reusable UI components with clear separation between props, slots, and HTML attributes. The changes add a new Component base class and Slot for flexible content insertion, update documentation to explain the new system, and update the public API to expose these new features.

Component System Implementation:

  • Added a new Component base class in src/nitro_ui/core/component.py that enables declarative, reusable components with a template() method, named slots, props/attribute separation, and class name merging.
  • Added a new Slot class (not shown in the diff but referenced) for marking content insertion points in component templates.

Public API and Exports:

  • Exposed Component and Slot in the NitroUI public API by updating src/nitro_ui/__init__.py and the __all__ list. [1] [2]
  • Updated project version to 1.0.6 in pyproject.toml.

Documentation and Guides:

  • Added a comprehensive design document for the new component system in docs/plans/2026-01-29-component-system-design.md, covering motivation, usage, API, and implementation details.
  • Updated SKILL.md and README.md with usage examples, migration notes, and best practices for building components and using slots, including new sections and code samples. [1] [2] [3] [4] [5] [6]

These changes provide a more robust, maintainable, and user-friendly way to develop UI components in NitroUI.

sn and others added 4 commits January 29, 2026 19:38
Defines a declarative, class-based system for building reusable
components with named slots, prop/attribute separation, and
class name merging.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a declarative component system with:
- Component base class with tag/class_name class attributes
- template() method for defining component structure
- Slot class for content insertion points (default + named slots)
- Automatic separation of props, slots, and HTML attributes
- Class name merging (user classes append to defaults)
- 34 new tests covering all functionality

Usage:
    class Card(Component):
        tag = "div"
        class_name = "card"

        def template(self, title: str):
            return [H3(title), Slot()]

    Card("Title", Paragraph("content"), footer=Button("OK"))

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace old HTMLElement subclassing examples with the new
declarative Component class pattern. Add named slots example.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sn sn self-assigned this Jan 29, 2026
@sn sn merged commit 81866b7 into main Jan 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant