Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Automatic linking of URLs, phone numbers, emails, etc. in strings for React Native

License

Notifications You must be signed in to change notification settings

conversocial/react-native-autolink

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Native AutoLink

NPM Version Build Status Dependency Status Dev Dependency Status

Auto-Linking component for React Native. Parses text and wraps URLs, phone numbers, emails, twitter handles, and hashtags with Text nodes and onPress handlers using the Autolinker.js.

Installation

npm install react-native-autolink --save

Usage

Simply import the library and pass desired props:

import Autolink from 'react-native-autolink';

class MyComponent extends Component {
  render() {
    return (
      <AutoLink
        text="This is the string to parse for urls (https://github.com/joshswan/react-native-autolink), phone numbers (415-555-5555), emails ([email protected]), twitter handles (@twitter), and hashtags (#exciting)"
        hashtag="instagram"
        twitter />
    );
  }
}

Props

Prop Type Default Description
text String Required. The string to parse for links.
email Boolean true Enable email linking (mailto:{email}).
hashtag Boolean/String false Enable hashtag linking to supplied service. Possible values: false, "instagram", "twitter".
phone Boolean true Enable phone linking (tel://{number}).
twitter Boolean false Enable Twitter handle linking (twitter://user?screen_name={handle}).
url Boolean true Enable url linking (https://{url}).
stripPrefix Boolean true Enable stripping of protocol from link text (https://url -> url).
linkStyle TextStyle Custom styling to apply to Text nodes of links.
onPress function Custom function handler for link press events. Arguments: link:String, match:Object. See Autolinker.js match object for more information about the match object.
renderLink function Custom render function for rendering link nodes. Arguments: text:String, link:String, match:Object. See Autolinker.js match object for more information about the match object.
truncate Number 32 Truncate long link text for display (e.g. https://www.google.com/../something.html). Possible values: 0 to disable, 1+ to truncate to that maximum length.
truncateChars String .. Characters to replace truncated url segments with, if enabled.

Any other props will be passed through to the main Text node (e.g. style, numberOfLines).

About

Automatic linking of URLs, phone numbers, emails, etc. in strings for React Native

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%