GithubHelp home page GithubHelp logo

mrmckeb / react-outline-manager Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 2.0 180 KB

A simple component to help manage focus outlines in React applications.

License: MIT License

JavaScript 33.55% TypeScript 66.45%

react-outline-manager's Introduction

React Outline Manager

license npm type definitions

A simple component to help manage focus outlines in React applications. No dependencies.

Includes CJS, ESM, and UMD (supporting browser usage) packages. TypeScript definitions are also included.

How it works

Unlike CSS-only solutions that simply hide outlines on focusable elements, this component can help you to create beautiful web apps without sacrificing accessibility.

When using this component, outlines on focusable elements are hidden until a user begins to interact with keyboard (specifically, the tab key). Optionally, resuming mouse/touch input can hide outlines again.

From version v1.2.0 and above, React v16.2+ is required due to the introduction of Fragment support.

Usage

To install with Yarn:

yarn add react-outline-manager

To install with npm:

npm install --save react-outline-manager

Once installed, simply import React Outline Manager and wrap your your application.

import ReactOutlineManager from 'react-outline-manager';

const MyAppWithOutlineManager = () => (
  <ReactOutlineManager>
    <YourApp />
  </ReactOutlineManager>
);

Only wrapped components will be affected. This means that you can also choose to only wrap a part of you application if desired.

Props

Prop Default value Description
className ReactOutlineManager Use this to change the class of the wrapping component. This class is only visible when outlines should be hidden.
tagName false Use this to change the element type used in the wrapping component, such as a div. When false (or omitted), this component renders as a Fragment and the className will be applied to the body tag.
toggle false By default, outlines are enabled when a user hits tab, but not hidden again. Set this option to true if you want outlines to toggle on and off as the user switches between input methods.

When tagName is set, you may also pass through standard React HTML props. For example:

<ReactOutlineManager onClick={() => {}} />

react-outline-manager's People

Contributors

mrmckeb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-outline-manager's Issues

Add a fragment prop

This feature would allow a user to use this component as a fragment, and would instead set the className to the body tag.

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.