• Resolved jasonsharp

    (@jasonsharp)


    What is the easiest way to apply css styling to the label on a custom form field? sorta like the one below? Say I want the text to be a specific font size.

    
    woocommerce_form_field('test', array(
    'type' => 'text',
    'label' => __('Location'),
    'required' => true
    ), $checkout->get_value('test'));
    
Viewing 1 replies (of 1 total)
  • Hi @jasonsharp,

    You can pass an HTML class for the label as part of the woocommerce_form_field()’s arguments. The easiest way to alter the appearance of only that label would be to add a unique class and then use it as a hook to change the label via CSS.

    The code to add the HTML class with the field might look like this:

    
    add_action( 'woocommerce_after_order_notes', 'wcforum_custom_checkout_field' );
    
    function wcforum_custom_checkout_field( $checkout ) {
    
        woocommerce_form_field( 'my_field_name', array(
            'type'          => 'text',
            'class'         => array('my-field-class form-row-wide'),
            'label'         => __('Fill in this field'),
    		'label_class'	=> array( 'custom-label-test' ),
            'placeholder'   => __('Enter something'),
            ), $checkout->get_value( 'my_field_name' ));
    
    }
    

    Hope that gets you pointed in the right direction.

Viewing 1 replies (of 1 total)
  • The topic ‘custom css for custom field label’ is closed to new replies.