Since version: v1.8.0
Filter acf_tablefield/formatting/nowrap_min_width
This filter sets a minimum width for the formatting option no wrap. By default a cell with no wrap never wraps its text. With a minimum width, the cell wraps normally while the table container is narrower than that width, for example on small screens. Above that width the cell stays on one line.
No wrap is meant for short content. See Cell formatting.
Parameters
add_filter( 'acf_tablefield/formatting/nowrap_min_width', function( $min_width, $field, $post_id ) {
return '600px';
}, 10, 3 );
-
$min_widthThe minimum width. Default
null: no wrap applies always. A number greater than 0 is taken as pixels. A string must be a number with the unitpx,emorrem, for example600px,40emor37.5rem. Everything else is the same asnull.
-
$fieldThe ACF field.
nullif the table is output from raw table data without a field.
-
$post_idThe post ID as passed to
get_table(),falsefor the current post.
Result
<div class="acftf-table-container" data-acftf-nowrap-min="600px"><table> … </table></div>
Output
If a minimum width is set, the table is output inside a container, but only if at least one cell has no wrap. The plugin adds a rule to the stylesheet that lets the no-wrap cells wrap while the container is narrower than the minimum width.
The container is an additional element around the table. Theme CSS that depends on the element structure, for example .entry-content > table, no longer matches the table.
The container is not used if the formatting is output as inline styles, see acf_tablefield/formatting/inline_styles. No wrap then always applies. If the filter acf_tablefield/formatting/enqueue_style returns false, the rule for the minimum width is not output and your theme has to style the container itself.