All Projects → tcodes0 → react-known-props

tcodes0 / react-known-props

Licence: BSD-3-Clause license
About 700 props React recognizes

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-known-props

sapa
sapa is a library that creates a UI with a simple event system.
Stars: ✭ 65 (+44.44%)
Mutual labels:  event
hepipe.js
Pipe arbitrary data rows (logs, events, cdrs, esl, etc) to HEP Server (HOMER)
Stars: ✭ 22 (-51.11%)
Mutual labels:  event
league-lazy-event
💤 Provides a LazyListener for use with League\Event which allows for lazy fetching of actual listeners.
Stars: ✭ 14 (-68.89%)
Mutual labels:  event
UT GameEventSystem
A flexible event system in Unreal Engine 4
Stars: ✭ 33 (-26.67%)
Mutual labels:  event
WELA
WELA (Windows Event Log Analyzer): The Swiss Army knife for Windows Event Logs! ゑ羅(ウェラ)
Stars: ✭ 442 (+882.22%)
Mutual labels:  event
website
Website of the JSCraftCamp in Munich
Stars: ✭ 35 (-22.22%)
Mutual labels:  event
react-translations-provider
React render props component for setting translations
Stars: ✭ 35 (-22.22%)
Mutual labels:  props
purescript-wire
Events and Signals for FRP. Monad instances included
Stars: ✭ 13 (-71.11%)
Mutual labels:  event
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+140%)
Mutual labels:  event
fine
🧹 Gracefully shutdown Node.js application: help you handle exit signals and cleanup
Stars: ✭ 20 (-55.56%)
Mutual labels:  event
react-trigger-change
Trigger React's synthetic change events on input, textarea and select elements
Stars: ✭ 63 (+40%)
Mutual labels:  event
hermes-js
Universal action dispatcher for JavaScript apps
Stars: ✭ 15 (-66.67%)
Mutual labels:  event
HiFramework.Unity
Based on component to manage project's core logic and module used in unity3d
Stars: ✭ 22 (-51.11%)
Mutual labels:  event
TrackAssemblyTool
A Garry's mod tool for assembing a prop-segmented track
Stars: ✭ 17 (-62.22%)
Mutual labels:  props
ReactiveBus
🚍 Reactive Event Bus for JVM (1.7+) and Android apps built with RxJava 2
Stars: ✭ 17 (-62.22%)
Mutual labels:  event
untrace
🐳 Minimal event tracking on the client in 300 bytes.
Stars: ✭ 26 (-42.22%)
Mutual labels:  event
akeneo-events-api-bundle
The Events API Bundle for Akeneo PIM delivers catalog changes as events to a 3rd party systems.
Stars: ✭ 18 (-60%)
Mutual labels:  event
egg-bus
🐣 用 egg 编写优雅的队列与事件
Stars: ✭ 38 (-15.56%)
Mutual labels:  event
add2calendar
📆 Allow you to add event to calendar easier
Stars: ✭ 51 (+13.33%)
Mutual labels:  event
three-onEvent
Add an EventListener for Object3d in your three.js project.(support click,hover or gaze)
Stars: ✭ 55 (+22.22%)
Mutual labels:  event

React Known Props Tweet

Build Status Latest version code style: prettier downloads/month


About 700 props React recognizes.

  • HTML & SVG props valid on any element (global props).
  • HTML & SVG element specific props.
  • ARIA props (includes role).
  • React event props.
  • React specific props.
  • Options you can set.

HTML attributes and React Properties are mixed together, the rationale is that if react accepts the prop, we include it. see #25 for more info

Install

install with

yarn add react-known-props
npm i react-known-props

then use with

import {
  getAllProps,
  getElementProps,
  getEventProps,
  getGlobalProps
} from "react-known-props";
const {
  getAllProps,
  getElementProps,
  getEventProps,
  getGlobalProps
} = require("react-known-props");

API

Functions provided

All functions return the props as strings in an array.

Element names are case-sensitive

  • HTML elements are all lowercase
  • SVG elements are lowercase and camelCase

See options below.

getAllProps

Gets all possible props: Global props, element specific props, event props and ARIA props including role.

// argument 1 (optional): an options object.

getAllProps();
getAllProps({ legacy: true });

// this
getAllProps().length;

// returns
675;

getElementProps

Gets all props valid on the HTML/SVG element provided as argument, plus all ARIA props, including role. Doesn't include event props.

// argument 1: string. Element to get props for.
// argument 2: (optional) an options object.

getElementProps("img")
getElementProps("iframe")
getElementProps("ellipse")
getElementProps("table", {legacy: true})
getElementProps("audio", {onlyReact: true})
getElementProps("polygon", {onlyReact: true})

// this
getElementProps("img")

// returns
[ 'align',
      'alt',
      'crossOrigin',
      'crossorigin',
      'height',
      'isMap',
      'ismap',
      'sizes',
      (...)
]

getEventProps

Gets React's event props only.

// arguments: none.

// this
getEventProps()

// returns
[ 'onBlur',
      'onChange',
      'onClick',
      'onContextMenu',
      'onCopy',
      'onCut',
      (...)
]

getGlobalProps

Gets all HTML and SVG props valid on any element, plus all ARIA props including role.

// argument 1 (optional): an options object.

getGlobalProps()
getGlobalProps({onlyReact: true})

// this
getGlobalProps()

// returns
[
  'accessKey',
  'accesskey',
  'autoCapitalize',
  'autocapitalize',
  'className',
  'class',
  'contentEditable',
  'contenteditable',
  (...)
]

Options

legacy

Default: false.

Whether or not to return deprecated HTML props bgcolor, border and color for the elements that still use them.

// examples:

// will include bgcolor in the props
getAllProps({ legacy: true });

// will omit legacy props
getAllProps({ legacy: false });

// same as {legacy: false}
getAllProps();

onlyReact

Default: false.

Whether to return only the React prop, or the HTML prop and the React prop. In React, some HTML props are renamed to camelCase (e.g. class -> className) and using the HTML lowercase name will show a warning. The same happens with SVG. Since the warning can be educational this option is off by default.

// examples:

// will include class and className, for and htmlFor, etc...
getElementProps("label");

// same as above
getElementProps("label", { onlyReact: false });

// no duplication, only React props are returned (itemID, tabIndex, autoCapitalize, className, htmlFor, etc...)
getGlobalProps({ onlyReact: true });

sort

Default: false*.

Sort the props alphabetically before returning them. It uses Array.prototype.sort.
*Not supported on getEventProps. Please sort it manually.

// examples:

getAllProps();
// not sorted
[
  (...)
  'aria-valuetext',
  'role',
  'accessKey',
  'accesskey',
  'autoCapitalize',
  'autocapitalize',
  'className',
  'class',
  (...)
]

// sorted
getAllProps({ sort: true });
getGlobalProps({ sort: true });

Incompatible SVG props not included.

React doesn't like all SVG props, some prevent it from compiling and print an error to the console. They are:

  • Props prefixed by xml:
  • Props prefixed by xlink:
  • Props prefixed by on (events)
  • ev:event

Need more props?

I'd use these packages:

  • Void HTML elements (self closing, e.g. <img/>): yarn add void-elements
  • Css props: yarn add known-css-properties

Contributing

Fork, make changes, run the build:lists script and send a PR. build:lists takes the stuff in src/generator and makes the files in src/generated. This is for performance reasons.

All data pulled from MDN web docs, official React docs, the ARIA specification and SVG specification. MDN can be a deep website to dig for info, I'm sure there are more props (specially legacy) waiting to be added by someone willing to look into every element page.

⚛️ React is awesome 💫

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].