question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to colour <ul><li> bullet points?

See original GitHub issue

I have tried this, but it doesn’t work:

ul: { color: '#fff' }, li: { color: '#fff' },

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
koenpuntcommented, Apr 3, 2017

For proper list alignment I found that I have to create a “table” with views.

So something like this:

// The function passed to the `renderNode` prop of the `HTMLView`
const customRenderer = (node, index, siblings, parent, domToElement) => {
  if (node.name === 'ol') {
    return (
      <List
        node={node}
        key={`node-${index}`}
        domToElement={domToElement}
      />
    );
  }
  return undefined;
};

// Custom List component
const List = ({ node, domToElement }) => (
  <View style={styles.list}>
    {node.children.filter(child => child.name === 'li').map((child, index) => (
      <View style={styles.listItem} key={index}>
        <View style={styles.listItemBullet}>
          {index + 1}
        </View>
        <View style={styles.listItemContent}>{domToElement(child.children, child)}</View>
      </View>
    ))}
  </View>
);

const styles = StyleSheet.create({
  listItem: {
    flexDirection: 'row',
    marginBottom: 10,
  },

  listItemBullet: {
    width: 20,
    paddingRight: 10,
  },

  listItemContent: {
    width: 0,
    flexGrow: 1,
  },
});

~However for this to work you have to use the github master, because domToElement is available in the function since 607ab6a805ca9aab448f3a910d610ae53a0708ee, which has not been released yet.~ nevermind, it’s in 0.9.0 now

0reactions
Quirksmodecommented, Apr 3, 2017

Thanks guys, this is really helpful, will give it a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Change Bullet Color of a List - W3Schools
Step 2) Add CSS: By default, it is not possible to change the bullet color of a list item. However, you can do...
Read more >
How to set Bullet colors in UL/LI html lists via CSS without ...
I found you can color the bullets by just using color:#ddd; on the li item itself. Here's an example. li{ color:#ff0000; list-style:square; } ......
Read more >
Change color of list bullet in blocks - LaTeX Stack Exchange
I want the list bullets in alerted blocks to be red and the otherwise in blue. The problem is that I don't manage...
Read more >
How To Change Bullet Point Color In Word - YouTube
HOW TO CHANGE BULLET POINT COLOR IN WORD // Watch this quick tutorial to learn how to make your bullet points a different...
Read more >
CSS: colored bullets and list numbers - W3C
Ever wanted to make a list with the bullets a different color than the text, like in this example? First item; First item....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found