You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							29 lines
						
					
					
						
							645 B
						
					
					
				
			
		
		
	
	
							29 lines
						
					
					
						
							645 B
						
					
					
				| // @flow
 | |
| import pixelsto from '../internalHelpers/_pxto'
 | |
| 
 | |
| /**
 | |
|  * Convert pixel value to rems. The default base value is 16px, but can be changed by passing a
 | |
|  * second argument to the function.
 | |
|  * @function
 | |
|  * @param {string|number} pxval
 | |
|  * @param {string|number} [base='16px']
 | |
|  * @example
 | |
|  * // Styles as object usage
 | |
|  * const styles = {
 | |
|  *   'height': rem('16px')
 | |
|  * }
 | |
|  *
 | |
|  * // styled-components usage
 | |
|  * const div = styled.div`
 | |
|  *   height: ${rem('16px')}
 | |
|  * `
 | |
|  *
 | |
|  * // CSS in JS Output
 | |
|  *
 | |
|  * element {
 | |
|  *   'height': '1rem'
 | |
|  * }
 | |
|  */
 | |
| const rem: (value: string | number, base?: string | number) => string = pixelsto('rem')
 | |
| export default rem
 |