Skip to content

⏳ Simple React component for displaying a timecode, with various formatting options.

License

Notifications You must be signed in to change notification settings

ryanhefner/react-timecode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

131 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⏳ react-timecode

npm version npm Coverage Status CircleCI Greenkeeper badge

Simple React component for displaying a timecode, with various formatting options.

Install

Via npm

npm install --save react-timecode

Via Yarn

yarn add react-timecode

How to use

The Timecode component is setup to be configurable as it needs to be, and hopefully nothing more. Below are the props you can set on the component, along with a simple example.

Properties

  • component:String|Function - Element to render the timecode within. (Default: span)
  • format:String - Specifies the format to display the timecode. (Default: H:?m:ss)
    • HH:mm:ss.sss - (Example: 00:01:23.876)
    • H:mm:ss.sss - (Example: 0:01:23.876)
    • H:?mm:ss.sss - (Example: 01:23.876)
    • H:?m:ss.sss - (Example: 1:23.876)
    • HH:mm:ss - (Example: 00:01:23)
    • H:mm:ss - (Example: 0:01:23)
    • H:?mm:ss - (Example: 01:23)
    • H:mm - (Example: 0:01)
    • H:?m:ss - (Example: 1:23 - Default)
  • postfix:String - Append a string after the formatted timecode.
  • prefix:String - Include a string before the formatted timecode.
  • time:Number - Time in milliseconds to display the timecode for. (Default: 0)

Example

import Timecode from 'react-timecode';

...

  render() {
    const {
      time,
    } = this.state;

    return (
      <Timecode time={time} />
    );
  }

...

Pairs well with...

License

MIT © Ryan Hefner

About

⏳ Simple React component for displaying a timecode, with various formatting options.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •