Giter VIP home page Giter VIP logo

using-keyboard's Introduction


<UsingKeyboard>

Bundlephobia Types Code coverage Build status NPM Version MIT License

npm i @accessible/using-keyboard

React utilities for adding accessible focus styles to elements when someone is using keyboard navigation.

Quick Start

import {
  UsingKeyboard,
  BodyUsingKeyboard,
  useUsingKeyboard,
} from '@accessibile/using-keyboard'

const App = (props) => (
  <UsingKeyboard className='using-keyboard'>
    <div className='my-app'>
      // This will have the class name 'my-app using-keyboard' // when a
      keyboard drew the last focus in a document. // That is, during keyboard
      navigation
    </div>
  </UsingKeyboard>
)

API

useUsingKeyboard(defaultUsingKeyboard)

A React hook that returns true when the keyboard was used more recently than the mouse for focusing an element.

Arguments

Argument Type Required Default Description
defaultUsingKeyboard boolean false false Sets the default value of usingKeyboard

Returns boolean

<BodyUsingKeyboard>

A React component that adds a using-keyboard class to the <body> when the keyboard was used more recently than the mouse for focusing an element. It removes the class each time a mousedown event fires.

Prop Type Required Default Description
className string false "using-keyboard" This is the class name that gets appended to the body
defaultUsingKeyboard boolean false false Sets the default value of usingKeyboard
children React.ReactElement false undefined By default this renders no children, but it will render any children you provide here.

<UsingKeyboard>

A React component that adds a using-keyboard class to its child element when the keyboard was used more recently than the mouse for focusing an element. It removes the class each time a mousedown event fires.

Prop Type Required Default Description
className string false "using-keyboard" This is the class name that gets appended to the child element
defaultUsingKeyboard boolean false false Sets the default value of usingKeyboard
children React.ReactElement false undefined By default this renders no children, but it will render any children you provide here.

LICENSE

MIT

using-keyboard's People

Contributors

jaredlunde avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.