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.

iOS compact style needs a width, is stuck left aligned

See original GitHub issue

I’m trying to use the new compact date picker style in iOS but I’n having a hard time styling it.

When I first put it in I got the following:

<DateTimePicker
    display="compact"
    mode="date"
    value={DateTime.local().toJSDate()}
/>
CleanShot 2020-11-16 at 17 09 50@2x

The date picker is the gray square on the right. I tried to set flex: 1 but that didn’t get things to display. Next I just set a width:

<DateTimePicker
    style={{width: 140}}
    display="compact"
    mode="date"
    value={DateTime.local().toJSDate()}
/>
CleanShot 2020-11-16 at 17 11 50@2x

Now I can see the date picker, but it’s too far to the left. I’d like to right align it. At this point I got stuck. Nothing I seemed to do right aligns the picker and because I don’t know the width (which is variable based on the contents).

Anyone run into this yet? any ideas?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:40
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
fjarrettcommented, Dec 23, 2020

While we wait for a more permanent fix, my dirty workaround ended up looking something like this:

<View style={{ alignItems: 'center', width: '100%' }}>
  <DateTimePicker
    display="compact"
    mode="datetime"
    style={{ width: 230 }}
    value={new Date()}
  />
</View>
1reaction
ASchwadcommented, Jan 11, 2022

A year has passed, any updates on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

css - Website Stuck in Left Alignment on iPad - Stack Overflow
1) Align center in body (You didn't do this) ... 3) specify width in container. 4) align left in container to undo center...
Read more >
SwiftUI Text Alignment Issue with Date and WidgetKit
When I preview this code in a traditional SwiftUI view, the code appears as expected; in the middle of the canvas (as there...
Read more >
How to Align and Float Images with CSS | Web Design
The following sections will explain how to float and align images using CSS. Left, Center, and Right Align. Images can be aligned left,...
Read more >
position - CSS: Cascading Style Sheets - MDN Web Docs
The position CSS property sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final ......
Read more >
columns - CSS-Tricks
Using both column-count and column-width is recommended to create a flexible multi-column layout. The column-count will act as the maximum ...
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