From 4763cc71c6ea4c278efe0a66599f0ab7e5ca212f Mon Sep 17 00:00:00 2001 From: Max Thirouin Date: Tue, 19 Nov 2019 21:13:59 +0100 Subject: [PATCH] Document reasoning behind hairlineWidth value Close #1488 --- packages/docs/src/apis/StyleSheet/StyleSheet.stories.mdx | 4 ++-- .../react-native-web/src/exports/StyleSheet/StyleSheet.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/docs/src/apis/StyleSheet/StyleSheet.stories.mdx b/packages/docs/src/apis/StyleSheet/StyleSheet.stories.mdx index bcd933f3..1f37691e 100644 --- a/packages/docs/src/apis/StyleSheet/StyleSheet.stories.mdx +++ b/packages/docs/src/apis/StyleSheet/StyleSheet.stories.mdx @@ -79,5 +79,5 @@ const styles = StyleSheet.create({ ### hairlineWidth -Enables borders of just one physical pixel on retina screens, otherwise it is -equal to a CSS value of 1px. +Equal to 1px. This is not implemented using screen density as browsers may +round sub-pixel values down to `0`, causing the line not to be rendered. diff --git a/packages/react-native-web/src/exports/StyleSheet/StyleSheet.js b/packages/react-native-web/src/exports/StyleSheet/StyleSheet.js index 43663259..7e9c293c 100644 --- a/packages/react-native-web/src/exports/StyleSheet/StyleSheet.js +++ b/packages/react-native-web/src/exports/StyleSheet/StyleSheet.js @@ -57,6 +57,9 @@ const StyleSheet = { return result; }, flatten: flattenStyle, + + // `hairlineWidth` is not implemented using screen density as browsers may + // round sub-pixel values down to `0`, causing the line not to be rendered. hairlineWidth: 1 };