All Projects → jaredpalmer → squeezy

jaredpalmer / squeezy

Licence: MIT license
1 kB React component for accessible accordions / collapse UI

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to squeezy

react-responsive-tabs
React responsive tabs http://maslianok.github.io/react-responsive-tabs/
Stars: ✭ 118 (+280.65%)
Mutual labels:  accordion
repromised
🤝 Declarative promise resolver as a render props component
Stars: ✭ 20 (-35.48%)
Mutual labels:  render-props
ListViewWithSubListView
Xamarin.Forms Expandable ListView With Sub-ListView MVVM Pattern
Stars: ✭ 40 (+29.03%)
Mutual labels:  accordion
esl
Lightweight and flexible UI component library based on web components technology for creating basic UX modules
Stars: ✭ 53 (+70.97%)
Mutual labels:  accordion
react-combine-contexts
🚀Use multiple React Contexts without pain.
Stars: ✭ 23 (-25.81%)
Mutual labels:  render-props
react-immer
No nonsense state management with Immer and React hooks
Stars: ✭ 13 (-58.06%)
Mutual labels:  render-props
vue-uix
Vue components based on the JUI components available in Vue.js
Stars: ✭ 15 (-51.61%)
Mutual labels:  accordion
Accordion.JS
Accordion.JS: Free jQuery Accordion plugin
Stars: ✭ 34 (+9.68%)
Mutual labels:  accordion
handy-collapse
A pure Javascript module for accordion/collapse UI without jQuery
Stars: ✭ 23 (-25.81%)
Mutual labels:  accordion
react-gearbox
⚙️📦 Gearbox - Renderless state provisioning and composition
Stars: ✭ 31 (+0%)
Mutual labels:  render-props
react-save-localstorage
🗄 React component to save data to localStorage on render phase safely
Stars: ✭ 26 (-16.13%)
Mutual labels:  render-props
react-callbag-listener
👂 A React render-prop component that listens to values emitted by callbags
Stars: ✭ 21 (-32.26%)
Mutual labels:  render-props
a11yAccordion
An accessible and easy to use Accordeon widget.
Stars: ✭ 37 (+19.35%)
Mutual labels:  accordion
react-collapse
Component-wrapper for collapse animation with CSS for elements with variable and dynamic height
Stars: ✭ 143 (+361.29%)
Mutual labels:  accordion
Accordion
Silky-smooth accordion widgets with no external dependencies.
Stars: ✭ 32 (+3.23%)
Mutual labels:  accordion
redebounce
↘️ Render Props component to debounce the given value
Stars: ✭ 14 (-54.84%)
Mutual labels:  render-props
Accordion-Collapse-react-native
React native Accordion/Collapse component, very good to use in toggles & show/hide content
Stars: ✭ 147 (+374.19%)
Mutual labels:  accordion
react-native-panel
A Customizable React Native Panel for Android and iOS
Stars: ✭ 35 (+12.9%)
Mutual labels:  accordion
react-virtual-container
Optimise your React apps by only rendering components when in proximity to the viewport.
Stars: ✭ 52 (+67.74%)
Mutual labels:  render-props
redux-render
Ergonomic Redux bindings for React using render functions
Stars: ✭ 54 (+74.19%)
Mutual labels:  render-props

Squeezy

An tiny 1KB React component for accessible accordions / collapse UI

npm i squeezy

Usage

import React from 'react';
import { Squeezy } from 'squeezy';

const App = () => (
  <div>
    <h1>My App</h1>

    <Squeezy
      id="thing"
      render={({ getButtonProps, getContentProps, isOpen }) => (
        <div>
          <div>
            Stuff
            <button {...getButtonProps({ className: 'whatever' })}>
              See {isOpen ? 'more' : 'less'}
            </button>
          </div>

          {isOpen ? (
            <div {...getContentProps({ className: '...' })}>Stuff to show</div>
          ) : null}
        </div>
      )}
    />
  </div>
);

export default App;

API

<Squeezy> Props

id: string

Required

An HTML id attribute. Used by Squeezy to make the accordion accessible.

debug?: boolean

Log changes to Squeezy state to the console.

isOpen?: boolean

If you want to make Squeezy a controlled component (i.e. manage its state externally), pass Squeezy an isOpen prop.

onToggle?: (state: SqueezyState, helpers: SqueezyActions) => void

Callback to run on state changes. If Squeezy is controlled, use this to set the next state externally. Otherwise, good place for side effects.

render: (props: SqueezyProps) => React.ReactNode

Render prop.

Squeezy State and Helpers

getButtonProps(moreProps: any) => void

Prop getter that returns accessible accordion button props and click handlers

getContentProps(moreProps: any) => void

Prop getter that returns accessible accordion content props. Spread this on the body / main area that you want show/hide

isOpen: boolean

Is the accordion open or close.

close: () => void

Close the accordion.

open: () => void

Open the accordion.

toggle: () => void

Toggle the accordion.

Inspiration

Author


MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].