Feature: new re-usable component system#6
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Componentbase class andSlotfor flexible content insertion, update documentation to explain the new system, and update the public API to expose these new features.Component System Implementation:
Componentbase class insrc/nitro_ui/core/component.pythat enables declarative, reusable components with atemplate()method, named slots, props/attribute separation, and class name merging.Slotclass (not shown in the diff but referenced) for marking content insertion points in component templates.Public API and Exports:
ComponentandSlotin the NitroUI public API by updatingsrc/nitro_ui/__init__.pyand the__all__list. [1] [2]1.0.6inpyproject.toml.Documentation and Guides:
docs/plans/2026-01-29-component-system-design.md, covering motivation, usage, API, and implementation details.SKILL.mdandREADME.mdwith 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.