2.1.1 • Published 16 days ago

@twocatmoon/react-slot v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

Contributors Forks Stargazers Issues MIT License

About The Project

React Slot implements a content distribution API inspired by Vue.js and the Web Components spec draft, using the <Slot> element to serve as distribution outlet for content.

This allows you to compose components like this:

<SectionHeader>
  <Slot name='title'>Hello</Slot>
  <Slot name='subtitle'>Lorem ipsum dolor sit amet.</Slot>
</SectionHeader>

Then in the template for <Header>, you might have:

const slots = findSlots(props.children)

return (
  <header>
    <h1>{slots.title}</h1>
    <p>{slots.subtitle}</p>
  </header>
)

Slots can contain any template code, including HTML or even other components.

Any children not contained inside of a <Slot> will be assigned to slots.defaultSlot.

Built With

Installation

  1. Install from NPM
    npm i @twocatmoon/react-slot
  2. Include in your project
    import { Slot, findSlots } from '@twocatmoon/react-slot'

Usage

Please refer to the Documentation

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Twitter - @twocatmoon

Project Link - https://github.com/twocatmoon/react-slot

Acknowledgments

2.1.1

16 days ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago