@genya/use-line-clamp@0.0.1
latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
JSR Score
23%
Published
4 weeks ago (0.0.1)
@genya/use-line-clamp
A React hook to toggle the visibility of components.
Installation
You can install the package via npm:
npm install @genya/use-line-clamp
or via yarn:
yarn add @genya/use-line-clamp
Usage
Basic Usage
Here's an example of how to use the useToggleVisibility
hook in your React component:
import React from 'react'; import { useToggleVisibility } from '@genya/use-line-clamp'; const MyComponent = (props: { message: string }) => { return <div>{props.message}</div>; }; const App = () => { const [ToggledComponent, toggleVisibility, isVisible] = useToggleVisibility(MyComponent, false); return ( <div> <button onClick={(e) => toggleVisibility(e)}> {isVisible ? 'Hide' : 'Show'} </button> <ToggledComponent message="Hello, World!" /> </div> ); }; export default App;
API
useToggleVisibility
const [Component, toggleVisibility, isVisible] = useToggleVisibility(WrappedComponent, initialVisibility);
Parameters
WrappedComponent
: The component to be toggled.initialVisibility
(optional): The initial visibility state of the component. Defaults tofalse
.
Returns
Component
: The wrapped component that will be conditionally rendered.toggleVisibility
: A function to toggle the visibility of the component. It can be called with an optional event and an optional boolean to explicitly set the visibility state.isVisible
: The current visibility state of the component.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Add Package
deno add jsr:@genya/use-line-clamp
Import symbol
import * as mod from "@genya/use-line-clamp";
---- OR ----
Import directly with a jsr specifier
import * as mod from "jsr:@genya/use-line-clamp";
Add Package
npx jsr add @genya/use-line-clamp
Import symbol
import * as mod from "@genya/use-line-clamp";
Add Package
yarn dlx jsr add @genya/use-line-clamp
Import symbol
import * as mod from "@genya/use-line-clamp";
Add Package
pnpm dlx jsr add @genya/use-line-clamp
Import symbol
import * as mod from "@genya/use-line-clamp";
Add Package
bunx jsr add @genya/use-line-clamp
Import symbol
import * as mod from "@genya/use-line-clamp";